package array;

public class P5_array_use {
    public static void main(String[] args) {
        int [] a = {1, 2, 3, 4, 5, 6};
        // 打印所有元素
        for(int i=0; i<a.length; i++)
        {
            System.out.println(a[i]);
        }
        // sum
        int sum = 0;
        for(int i=0; i<=a.length-1; i++)
        {
            sum += a[i];
        }
        System.out.println("sum: "+sum);
        // max
        int max = a[0];
        for(int i=1; i<=a.length-1; i++)
        {
            if(a[i]>max)
            {
                max = a[i];
            }
        }
        System.out.println("max: "+max);

    }


}
